using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace CocaCola_Inventory_System.Forms
{
    public partial class Switchboard : Form
    {
        #region threading part for splash

        private static Switchboard singeltonSplashScreen;
        private static ManualResetEvent splashScreenCreatedEvent = new ManualResetEvent(false);
        private delegate void changeSplashScreen();

        public static void showSplash()
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(startSplash));
        }

        public static void startSplash(object o)
        {
            Switchboard splashScreen = new Switchboard();

            singeltonSplashScreen = splashScreen;

            Application.Run(splashScreen);
        }

        public static void closeSplash()
        {
            splashScreenCreatedEvent.WaitOne();
            singeltonSplashScreen.BeginInvoke(new changeSplashScreen(singeltonSplashScreen.stopSplash));
        }

        private void stopSplash()
        {
            Close();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            splashScreenCreatedEvent.Set();

        }
        #endregion

        public Switchboard()
        {
            InitializeComponent();
        }

        #region commented part
        private void Switch_Load(object sender, EventArgs e)
        {
        //    backgroundWorker1.RunWorkerAsync();
            
        }

        //private void button1_Click(object sender, EventArgs e)
        //{
        //    Application.Exit();
        //}

        //private void button2_Click(object sender, EventArgs e)
        //{
        //    Form1 f = new Form1();
        //    f.Show();
        //    this.Hide();
        //}

        //private void button3_Click(object sender, EventArgs e)
        //{
        //    search s = new search();
        //    s.Show();
        //    this.Hide();

        //}

        //private void button4_Click(object sender, EventArgs e)
        //{
        //    MessageBox.Show(" KO IT Department Inventory System  \n \n Done by \n Kamal Haggag , \n Mahmoud Saleh , \n Yasser Zayan ", "About");
        //}
        #endregion

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {

            Thread.Sleep(2500);
            
        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Container c = new Container();
            c.Show();
            this.Hide();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (label2.Text == "")
                label2.Text = ".";
            else if (label2.Text == ".")
                label2.Text = "..";
            else if (label2.Text == "..")
                label2.Text = "...";
            else if (label2.Text == "...")
                label2.Text = "";

        }

        
    }
}